/* GUI CONVERTED from soiviq01.p (converter v1.76) Fri Dec 27 23:24:36 2002 */
/* soiviq01.p - INVOICE HISTORY TRACKING INQUIRY                              */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.6.1.11 $                                                       */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 5.0      LAST MODIFIED: 01/17/90   BY: ftb *B511**/
/* REVISION: 6.0      LAST MODIFIED: 04/16/90   BY: ftb *D002**/
/* REVISION: 6.0      LAST MODIFIED: 12/28/90   BY: afs *D278**/
/* REVISION: 6.0      LAST MODIFIED: 02/02/91   BY: pml *F142**/
/* REVISION: 7.0      LAST MODIFIED: 03/19/92   BY: afs *F299**/
/* REVISION: 7.3      LAST MODIFIED: 11/16/92   BY: afs *G324**/
/* REVISION: 7.3      LAST MODIFIED: 08/24/93   BY: afs *GE46**/
/* REVISION: 7.3      LAST MODIFIED: 09/14/93   BY: afs *GF24**/
/* REVISION: 7.3      LAST MODIFIED: 04/28/94   BY: jjs *GJ65**/
/* REVISION: 7.3      LAST MODIFIED: 10/25/94   BY: ljm *GN54**/
/* REVISION: 7.3      LAST MODIFIED: 03/31/95   BY: JPM *G0K2**/
/* REVISION: 7.3      LAST MODIFIED: 09/15/95   BY: JYM *G0X4**/
/* REVISION: 7.3      LAST MODIFIED: 12/04/95   BY: AIS *G1FJ**/
/* REVISION: 7.3      LAST MODIFIED: 08/26/96   BY: *G2D1* Aruna P. Patil     */
/* REVISION: 8.6      LAST MODIFIED: 10/13/97   BY: GYK *K0WC*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 04/11/00   BY: *M0HV* Sachin Shinde      */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.6.1.10    BY: Jean Miller        DATE: 05/26/02  ECO: *P076*  */
/* $Revision: 1.6.1.11 $   BY: Seema Tyagi        DATE: 12/27/02  ECO: *N22R*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define variable inv like ih_inv_nbr.
define variable inv_date like ih_inv_date.
define variable cust like ih_cust.
define variable nbr like ih_nbr.
define variable part like idh_part.
define variable po like ih_po.
define variable site like ih_site.
define variable qty_bo like idh_bo_chg.
define variable qty_open like idh_qty_ord label "Qty Open".
define variable quote like ih_quote.
define variable firsttime like mfc_logical no-undo.
define variable l_qty_ord like itm_qty_call format "->,>>>,>>9.9<<<<<<<" no-undo.
define variable l_qty_inv like idh_qty_inv no-undo.
define variable l_sort    like ad_sort     no-undo.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   inv
   po
   nbr
   quote
   cust
with frame a no-underline width 80 attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   ih_inv_nbr   colon 15
   ih_inv_date  colon 38
   ih_req_date  colon 62 skip
   ih_nbr       colon 15
   ih_ord_date  colon 38
   ih_due_date  colon 62 skip
   ih_po        colon 15
   ih_quote     colon 62 skip
   ih_cust      colon 15
         skip   
   /*V8+*/
         ih_ship    colon 15   
   ad_mstr.ad_city no-label
   ad_mstr.ad_st no-label skip
   ih_shipvia   colon 15
   ih_ship_date colon 62
   ih_bol       colon 15
with STREAM-IO /*GUI*/  frame invhdr width 80 no-attr-space
title color normal (getFrameTitle("INVOICE_HISTORY",23)) side-labels.

/* SET EXTERNAL LABELS */
setFrameLabels(frame invhdr:handle).

FORM /*GUI*/ 
   so_nbr       colon 15
         skip   
   /*V8+*/
         so_ord_date colon 15   
   so_req_date  colon 62 skip
   so_po        colon 15
   so_stat      colon 62 skip
   so_cust      colon 15
   ad_mstr.ad_sort no-label skip
   so_ship      colon 15
   ad_mstr.ad_name no-label format "x(26)"
   ad_mstr.ad_city no-label
   ad_mstr.ad_st no-label skip
   so_shipvia   colon 15
   so_ship_date colon 62
   so_bol       colon 15
   so_quote     colon 62
with STREAM-IO /*GUI*/  frame sohdr side-labels width 80 no-attr-space
title color normal (getFrameTitle("SALES_ORDER",17)).

/* SET EXTERNAL LABELS */
setFrameLabels(frame sohdr:handle).

FORM /*GUI*/ 
   idh_line
   idh_part
   idh_site
   idh_um
   idh_qty_ord
   idh_qty_inv
   idh_due_date
with STREAM-IO /*GUI*/  down frame idhhist width 80 no-attr-space
title color normal (getFrameTitle("LINE_ITEMS",16)).

/* SET EXTERNAL LABELS */
setFrameLabels(frame idhhist:handle).

FORM /*GUI*/ 
   idh_line
   idh_part
   idh_site
   idh_um
   l_qty_ord
   l_qty_inv
   idh_due_date
with STREAM-IO /*GUI*/  down frame idhhist1 width 80 no-attr-space
title color normal (getFrameTitle("LINE_ITEMS",16)).

/* SET EXTERNAL LABELS */
setFrameLabels(frame idhhist1:handle).

FORM /*GUI*/ 
   sod_line
   sod_part
   sod_site
   sod_um
   sod_qty_ord
   qty_open
   sod_due_date
with STREAM-IO /*GUI*/  down frame soddet no-attr-space width 80
title color normal (getFrameTitle("LINE_ITEMS",16)).

/* SET EXTERNAL LABELS */
setFrameLabels(frame soddet:handle).

FORM /*GUI*/ 
   sod_line
   sod_part
   sod_site
   sod_um
   l_qty_ord
   qty_open
   sod_due_date
with STREAM-IO /*GUI*/  down frame soddet1 no-attr-space width 80
title color normal (getFrameTitle("LINE_ITEMS",16)).

/* SET EXTERNAL LABELS */
setFrameLabels(frame soddet1:handle).

{wbrp01.i}
repeat:

   if c-application-mode <> 'web' then
   update
      inv
      po
      nbr
      quote
      cust
   with frame a
   editing:

      if frame-field = "inv" then do:
         /* FIND NEXT/PREVIOUS RECORD */
         {mfnp.i ih_hist inv ih_inv_nbr inv ih_inv_nbr ih_inv_nbr}
         if recno <> ? then do:
            inv = ih_inv_nbr.
            display inv with frame a.
            recno = ?.
         end.
      end.
      else do:
         status input.
         readkey.
         apply lastkey.
      end.

   end.

   {wbrp06.i &command = update &fields = "  inv po nbr quote cust"
      &frm = "a"}

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal"
               &printWidth = 80
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}

   hide frame invhdr.
   hide frame sohdr.
   hide frame idhhist.
   hide frame soddet.
   hide frame idhhist1.
   hide frame soddet1.

   /* THE FOLLOWING SECTION OF CODE HAS BEEN MOVED */
   /* TO THE INTERNAL PROCEDURE disp_det */
   {hksimsg.i """" """"}    /*fdn*/

   run disp_det.

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}

end. /* REPEAT */

{wbrp04.i &frame-spec = a}

PROCEDURE disp_det:

   if inv <> "" then do:

      loopb:
      for each ih_hist
         fields(ih_bol ih_cust ih_due_date ih_fsm_type
                ih_inv_date ih_inv_nbr ih_nbr ih_ord_date
                ih_po ih_quote ih_req_date ih_ship
                ih_shipvia ih_ship_date)
         where ih_inv_nbr = inv
           and (ih_po = po or po = "")
           and (ih_nbr = nbr or nbr = "")
           and (ih_cust = cust or cust = "")
           and (ih_quote = quote or  quote = "")
          AND LOOKUP(ih_site,GLOBAL_user_site) > 0
      no-lock with frame invhdr:

         /* DISPLAY INVOICE HEADER AND DETAIL LINES */
         {soiviq1a.i &loop = loopb}

         for each so_mstr
            fields(so_bol so_cust so_fsm_type so_nbr
                   so_ord_date so_po so_quote so_req_date
                   so_ship so_shipvia so_ship_date so_stat)
            where so_nbr = ih_nbr
              and (so_po = po or po = "")
              and (so_nbr = nbr or nbr = "")
              and (so_cust = cust or cust = "")
              and (so_quote = quote or quote = "")
         no-lock with frame sohdr:

            hide frame idhhist.
            hide frame idhhist1.
            hide frame invhdr.

            /* DISPLAY SALES ORDER HEADER AND DETAIL LINES */
            {soiviq1b.i}

         end. /* SO_MSTR */

         hide frame soddet.
         hide frame soddet1.
         hide frame sohdr.

      end. /* LOOPB */

      hide frame idhhist.
      hide frame idhhist1.
      hide frame invhdr.

   end.  /* IF INV <> "" */

   else if po <> ""
   then do:

      loopd:
      for each ih_hist
         fields(ih_bol ih_cust ih_due_date ih_fsm_type
                ih_inv_date ih_inv_nbr ih_nbr ih_ord_date
                ih_po ih_quote ih_req_date ih_ship
                ih_shipvia ih_ship_date)
         where ih_po = po
           and (ih_nbr = nbr or nbr = "")
           and (ih_cust = cust or cust = "")
           and (ih_quote = quote or quote = "")
          AND LOOKUP(ih_site,GLOBAL_user_site) > 0
      no-lock by ih_inv_nbr with frame invhdr:

         /* DISPLAY INVOICE HEADER AND DETAIL LINES */
         {soiviq1a.i &loop = loopd}

      end. /* LOOPD */

      hide frame idhhist.
      hide frame idhhist1.
      hide frame invhdr.

      loope:
      for each so_mstr
         fields(so_bol so_cust so_fsm_type so_nbr
                so_ord_date so_po so_quote so_req_date
                so_ship so_shipvia so_ship_date so_stat)
         where so_po = po
           and (so_nbr = nbr or nbr = "")
           and (so_cust = cust or cust = "")
           and (so_quote = quote or quote = "")
      no-lock with frame sohdr:

         /* DISPLAY SALES ORDER HEADER AND DETAIL LINES */
         {soiviq1b.i}

      end. /* LOOPE */

      hide frame soddet.
      hide frame soddet1.
      hide frame sohdr.

   end. /* IF PO <> "" */

   else if nbr <> ""
   then do:

      loopf:
      for each ih_hist
         fields(ih_bol ih_cust ih_due_date ih_fsm_type
                ih_inv_date ih_inv_nbr ih_nbr ih_ord_date
                ih_po ih_quote ih_req_date ih_ship
                ih_shipvia ih_ship_date)
         where ih_nbr = nbr
           and (ih_cust = cust or cust = "")
           and (ih_quote = quote or quote = "")
          AND LOOKUP(ih_site,GLOBAL_user_site) > 0
      no-lock by ih_inv_nbr with frame invhdr:

         /* DISPLAY INVOICE HEADER AND DETAIL LINES */
         {soiviq1a.i &loop = loopf}

      end. /* LOOPF */

      hide frame idhhist.
      hide frame idhhist1.
      hide frame invhdr.

      loopg:
      for each so_mstr
         fields(so_bol so_cust so_fsm_type so_nbr
                so_ord_date so_po so_quote so_req_date
                so_ship so_shipvia so_ship_date so_stat)
         where so_nbr = nbr
         and (so_cust = cust or cust = "")
         and (so_quote = quote or quote = "")
      no-lock with frame sohdr.

         /* DISPLAY SALES ORDER HEADER AND DETAIL LINES */
         {soiviq1b.i}

      end. /* LOOPG */

      hide frame soddet.
      hide frame soddet1.
      hide frame sohdr.

   end. /* IF NBR <> "" */

   else if quote <> ""
   then do:

      looph:
      for each ih_hist
         fields(ih_bol ih_cust ih_due_date ih_fsm_type
                ih_inv_date ih_inv_nbr ih_nbr ih_ord_date
                ih_po ih_quote ih_req_date ih_ship
                ih_shipvia ih_ship_date)
         where ih_quote = quote
         AND LOOKUP(ih_site,GLOBAL_user_site) > 0
      no-lock by ih_ship_date descending with frame invhdr:

         /* DISPLAY INVOICE HEADER AND DETAIL LINES */
         {soiviq1a.i &loop = looph}

      end. /* LOOPH */

      hide frame idhhist.
      hide frame idhhist1.
      hide frame invhdr.

      loopi:
      for each so_mstr
         fields(so_bol so_cust so_fsm_type so_nbr
                so_ord_date so_po so_quote so_req_date
                so_ship so_shipvia so_ship_date so_stat)
         where so_quote = quote
           and (so_cust = cust or cust = "")
      no-lock with frame sohdr:

         /* DISPLAY SALES ORDER HEADER AND DETAIL LINES */
         {soiviq1b.i}

      end. /* LOOPI */

      hide frame soddet.
      hide frame soddet1.
      hide frame sohdr.

   end. /* IF QUOTE <> "" */

   else if cust <> ""
   then do:

      loopj:
      for each ih_hist
         fields(ih_bol ih_cust ih_due_date ih_fsm_type
                ih_inv_date ih_inv_nbr ih_nbr ih_ord_date
                ih_po ih_quote ih_req_date ih_ship
                ih_shipvia ih_ship_date)
         where ih_cust = cust
         AND LOOKUP(ih_site,GLOBAL_user_site) > 0
      no-lock by ih_ship_date descending with frame invhdr:

         /* DISPLAY INVOICE HEADER AND DETAIL LINES */
         {soiviq1a.i &loop = loopj}

      end. /* LOOPJ */

      hide frame idhhist.
      hide frame idhhist1.
      hide frame invhdr.

      loopk:
      for each so_mstr
         fields(so_bol so_cust so_fsm_type so_nbr
                so_ord_date so_po so_quote so_req_date
                so_ship so_shipvia so_ship_date so_stat)
         where (so_cust = cust or cust = "")
      no-lock with frame sohdr:

         /* DISPLAY SALES ORDER HEADER AND DETAIL LINES */
         {soiviq1b.i}

      end. /* LOOPK */

      hide frame soddet.
      hide frame soddet1.
      hide frame sohdr.

   end. /* IF CUST <> "" */

END PROCEDURE.
